﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BI
{
    public partial class UcDigitalNumber : UserControl
    {
        public string DisplayText{
            get{
                return digitalGauge1.Text;
            }
            set
            {
                digitalGauge1.Text = value;
            }
        }
        ToolTip _ToolTip = new ToolTip();

        public UcDigitalNumber()
        {
            InitializeComponent();
            _ToolTip.OwnerDraw = true;
            _ToolTip.Draw += new DrawToolTipEventHandler(toolTip_Draw);
            _ToolTip.Popup += new PopupEventHandler(ToolTip_Popup);
        }

        void ToolTip_Popup(object sender, PopupEventArgs e)
        {
            Size oldSize = e.ToolTipSize;
            Control parent = e.AssociatedControl;
            Image toolTipImage = parent.Tag as Image;
            oldSize.Width += 60;
            e.ToolTipSize = oldSize;
        }

        private void gaugeControl1_MouseHover(object sender, EventArgs e)
        {
            if (this.gaugeControl1.Tag != null)
            {
                _ToolTip.Show(this.gaugeControl1.Tag.ToString(), this, new Point(30, 30));
            }
        }
        void toolTip_Draw(object sender, DrawToolTipEventArgs e)
        {
            Font f = new Font("Tahoma", 8.0f);
            _ToolTip.BackColor = System.Drawing.Color.Yellow;
            e.DrawBackground();
            e.DrawBorder();
            e.Graphics.DrawString(e.ToolTipText, f, Brushes.Black, new PointF(2, 2));
        }

        private void gaugeControl1_MouseLeave(object sender, EventArgs e)
        {
            _ToolTip.RemoveAll();
        }
    }
}
